| Conditions | 1 |
| Paths | 1 |
| Total Lines | 124 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /* |
||
| 92 | $(document).ready(function () { |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @constructs Navigation |
||
| 96 | */ |
||
| 97 | var Navigation = function () { |
||
| 98 | |||
| 99 | $.extend(Navigation.prototype, curr); |
||
| 100 | $.extend(Navigation.prototype, nav); |
||
| 101 | $.extend(Navigation.prototype, elements); |
||
| 102 | $.extend(Navigation.prototype, actions); |
||
| 103 | $.extend(Navigation.prototype, settings); |
||
| 104 | $.extend(Navigation.prototype, resultCircles); |
||
| 105 | $.extend(Navigation.prototype, resultMembers); |
||
| 106 | $.extend(Navigation.prototype, resultLinks); |
||
| 107 | |||
| 108 | this.init(); |
||
| 109 | this.initTransifex(); |
||
| 110 | this.retrieveSettings(); |
||
| 111 | }; |
||
| 112 | |||
| 113 | |||
| 114 | Navigation.prototype = { |
||
| 115 | |||
| 116 | init: function () { |
||
| 117 | elements.initElements(); |
||
| 118 | elements.initUI(); |
||
| 119 | elements.initTweaks(); |
||
| 120 | elements.initAnimationNewCircle(); |
||
| 121 | elements.initExperienceCirclesList(); |
||
| 122 | elements.initExperienceCircleButtons(); |
||
| 123 | //elements.initExperienceMemberDetails(); |
||
| 124 | nav.initNavigation(); |
||
| 125 | }, |
||
| 126 | |||
| 127 | initTransifex: function () { |
||
| 128 | t('circles', 'Personal Circle'); |
||
| 129 | t('circles', 'Hidden Circle'); |
||
| 130 | t('circles', 'Private Circle'); |
||
| 131 | t('circles', 'Public Circle'); |
||
| 132 | |||
| 133 | t('circles', 'Personal'); |
||
| 134 | t('circles', 'Hidden'); |
||
| 135 | t('circles', 'Private'); |
||
| 136 | t('circles', 'Public'); |
||
| 137 | |||
| 138 | t('circles', 'Not a member'); |
||
| 139 | t('circles', 'Member'); |
||
| 140 | t('circles', 'Moderator'); |
||
| 141 | t('circles', 'Admin'); |
||
| 142 | t('circles', 'Owner'); |
||
| 143 | |||
| 144 | t('circles', 'Unknown'); |
||
| 145 | t('circles', 'Invited'); |
||
| 146 | t('circles', 'Requesting'); |
||
| 147 | t('circles', 'Blocked'); |
||
| 148 | t('circles', 'Kicked'); |
||
| 149 | }, |
||
| 150 | |||
| 151 | retrieveSettings: function () { |
||
| 152 | var self = this; |
||
| 153 | |||
| 154 | $.ajax({ |
||
| 155 | method: 'GET', |
||
| 156 | url: OC.generateUrl('/apps/circles/settings'), |
||
| 157 | }).done(function (result) { |
||
| 158 | self.retrieveSettingsResult(result) |
||
| 159 | }).fail(function () { |
||
| 160 | self.retrieveSettingsResult({status: -1}); |
||
| 161 | }); |
||
| 162 | }, |
||
| 163 | |||
| 164 | retrieveSettingsResult: function (result) { |
||
| 165 | if (result.status !== 1) { |
||
| 166 | return; |
||
| 167 | } |
||
| 168 | |||
| 169 | curr.allowed_federated = result.allowed_federated; |
||
| 170 | curr.allowed_circles = result.allowed_circles; |
||
| 171 | |||
| 172 | var circleId = window.location.hash.substr(1); |
||
| 173 | if (circleId) { |
||
| 174 | actions.selectCircle(circleId); |
||
| 175 | } |
||
| 176 | } |
||
| 177 | |||
| 178 | }; |
||
| 179 | |||
| 180 | |||
| 181 | /** |
||
| 182 | * @constructs Notification |
||
| 183 | */ |
||
| 184 | var Notification = function () { |
||
| 185 | this.initialize(); |
||
| 186 | }; |
||
| 187 | |||
| 188 | Notification.prototype = { |
||
| 189 | |||
| 190 | initialize: function () { |
||
| 191 | |||
| 192 | //noinspection SpellCheckingInspection |
||
| 193 | var notyf = new Notyf({ |
||
| 194 | delay: 5000 |
||
| 195 | }); |
||
| 196 | |||
| 197 | this.onSuccess = function (text) { |
||
| 198 | notyf.confirm(text); |
||
| 199 | }; |
||
| 200 | |||
| 201 | this.onFail = function (text) { |
||
| 202 | notyf.alert(text); |
||
| 203 | }; |
||
| 204 | |||
| 205 | } |
||
| 206 | |||
| 207 | }; |
||
| 208 | |||
| 209 | OCA.Circles.Navigation = Navigation; |
||
| 210 | OCA.Circles.navigation = new Navigation(); |
||
| 211 | |||
| 212 | OCA.Notification = Notification; |
||
| 213 | OCA.notification = new Notification(); |
||
| 214 | |||
| 215 | }); |
||
| 216 | |||
| 217 |